
//
//  SortTableViewCell.m
//  GoShops
//
//  Created by zcj on 15-12-4.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "SortTableViewCell.h"
#import "Grouble.h"

@implementation SortTableViewCell

+(instancetype)SortTableViewCell:(UITableView *)tableView
{
    static NSString *ID = @"ccslidesort";
    SortTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[SortTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    // 设置不能选中,选中每反应
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //筛选
        UIView *filterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 140)];
        filterView.backgroundColor = [UIColor whiteColor];
        filterView.userInteractionEnabled = YES;
        [self addSubview:filterView];
        
        NSArray *filterName = @[@"品牌",@"全城",@"离我最近",@"特效"];
        
        //筛选
        for (int i = 0; i < 4; i++) {
            //文字
            UIButton *filterBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            filterBtn.frame = CGRectMake(i*ScreenWidth/4, 0, ScreenWidth/4-15, 40);
            filterBtn.tag = 100+i;
            filterBtn.titleLabel.font = [UIFont systemFontOfSize:13];
            [filterBtn setTitle:filterName[i] forState:UIControlStateNormal];
            [filterBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            // 设置选中按钮的颜色
            
            [filterBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            // 点击按钮
            [filterBtn addTarget:self action:@selector(OnFilterBtn:) forControlEvents:UIControlEventTouchUpInside];
            if (i == 0) {
                filterBtn.selected = YES;
            }
            [filterView addSubview:filterBtn];
            
            //三角
            UIButton *triangleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            triangleBtn.frame = CGRectMake((i+1)*ScreenWidth/4-15, 16, 8, 7);
            triangleBtn.tag = 120+i;
            [triangleBtn setImage:[UIImage imageNamed:@"icon_arrow_dropdown_normal"] forState:UIControlStateNormal];
            [triangleBtn setImage:[UIImage imageNamed:@"icon_arrow_dropdown_selected"] forState:UIControlStateSelected];
            [filterView addSubview:triangleBtn];
        }
        //搞一个下划线
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 39.5+60, ScreenWidth, 0.5)];
        lineView.backgroundColor = ZCJColor(192, 192, 192);
        [filterView addSubview:lineView];

        // Initialization code
    }
    return self;
}
- (void)OnFilterBtn:(UIGestureRecognizer *)gester
{
    ZCJLog(@"kdljkfodfjkl");
}
- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
